<%@ page import="com.zhongkun.pojo.Picture" %>
<%@ page import="com.zhongkun.pojo.UserShare" %>
<%@ page import="com.zhongkun.pojo.User" %>
<%@ page import="com.zhongkun.pojo.Comment" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.stream.Collectors" %>
<%@ page import="java.util.Iterator" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html class="no-js" lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <title>首页-发现下一个好朋友~</title>
    <meta name="robots" content="noindex, follow" />
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <!-- Favicon -->
    <link rel="shortcut icon" type="image/x-icon" href="${pageContext.request.contextPath}/assets/images/favicon.ico">

    <!-- CSS
	============================================ -->
    <!-- google fonts -->
    <link href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,500,500i,700,700i,900" rel="stylesheet">
    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/assets/css/vendor/bootstrap.min.css">
    <!-- Icon Font CSS -->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/assets/css/vendor/bicon.min.css">
    <!-- Flat Icon CSS -->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/assets/css/vendor/flaticon.css">
    <!-- audio & video player CSS -->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/assets/css/plugins/plyr.css">
    <!-- Slick CSS -->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/assets/css/plugins/slick.min.css">
    <!-- nice-select CSS -->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/assets/css/plugins/nice-select.css">
    <!-- perfect scrollbar css -->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/assets/css/plugins/perfect-scrollbar.css">
    <!-- light gallery css -->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/assets/css/plugins/lightgallery.min.css">
    <!-- Main Style CSS -->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/assets/css/style.css">


</head>

//写几个全局方法吧
<%!
    String findSharePic(int id,List<Picture> picture){
        List<Picture> pic = picture.stream().filter(p->p.getId() == id).collect(Collectors.toList());
        if (pic.size()<1 || pic.size()>1){
            System.out.println("这图有问题啊");
            return "错误";
        }
        return pic.get(0).getPath();
    }

    String findShareUser(int id,List<User> users){
        List<User> user = users.stream().filter(u->u.getId() == id).collect(Collectors.toList());
        if (user.size()<1 || user.size()>1){
            System.out.println("这用户有问题啊");
            return "错误";
        }
        return user.get(0).getNikename();
    }

    String findShareProfile(int id,List<User> users,List<Picture> picture){
        List<User> user = users.stream().filter(u->u.getId() == id).collect(Collectors.toList());
        if (user.size()<1 || user.size()>1){
            System.out.println("这头像有问题啊");
            return "错误";
        }
        return findSharePic(user.get(0).getProfile(),picture);
    }

%>

<%
    User user = (User)request.getSession().getAttribute("userLogin");
    Picture pic = (Picture) request.getSession().getAttribute("profilePath");
    List<Picture> pictureList = (List<Picture>) request.getSession().getAttribute("allPicture");
    List<UserShare> userShareTime = (List<UserShare>) request.getSession().getAttribute("share");
    List<UserShare> userShareHot = (List<UserShare>) request.getSession().getAttribute("shareHot");
    List<User> users = (List<User>) request.getSession().getAttribute("allUserByTime");
    //Comment comment = (Comment) request.getSession().getAttribute("comment");

%>

<body>

<!-- header area start -->
<header>
    <div class="header-top sticky bg-white d-none d-lg-block">
        <div class="container">
            <div class="row align-items-center">
                <div class="col-md-5">
                    <!-- header top navigation start -->
                    <div class="header-top-navigation">
                        <nav>
                            <ul>
                                <li class="active"><a href="/file/mainAfterLogin">首页</a></li>
                                <!-- <li class="msg-trigger"><a class="msg-trigger-btn" href="#a">个人主页</a>

                                </li> -->
                                <li class="notification-trigger"><a class="msg-trigger-btn" href="#b">个人主页</a>

                                </li>
                            </ul>
                        </nav>
                    </div>
                    <!-- header top navigation start -->
                </div>

                <div class="col-md-2">
                    <!-- brand logo start -->
                    <div class="brand-logo text-center">
                        <a href="/file/mainAfterLogin">
                            <img src="${pageContext.request.contextPath}/assets/images/logo/logo.png" alt="brand logo">
                        </a>
                    </div>
                    <!-- brand logo end -->
                </div>

                <div class="col-md-5">
                    <div class="header-top-right d-flex align-items-center justify-content-end">
                        <!-- header top search start -->
                        <div class="header-top-search">
                            <form class="top-search-box">
                                <input type="text" placeholder="搜你所想" class="top-search-field">
                                <button class="top-search-btn"><i class="flaticon-search"></i></button>
                            </form>
                        </div>
                        <!-- header top search end -->

                        <!-- profile picture start -->
                        <div class="profile-setting-box">
                            <div class="profile-thumb-small">
                                <a href="javascript:void(0)" class="profile-triger">
                                    <figure>
                                        <img src="<%= pic.getPath()%>" alt="profile picture">
                                    </figure>
                                </a>
                                <div class="profile-dropdown">
                                    <div class="profile-head">
                                        <h5 class="name"><a href="#"><%= user.getNikename()%></a></h5>
                                        <a class="mail" href="#"><%= user.getUsername()%></a>
                                    </div>
                                    <div class="profile-body">
                                        <ul>
                                            <li><a href="profile.html"><i class="flaticon-user"></i>个人中心</a></li>
                                            <li><a href="#"><i class="flaticon-message"></i>#待添加</a></li>
                                            <li><a href="#"><i class="flaticon-document"></i>动态</a></li>
                                        </ul>
                                        <ul>
                                            <li><a href="signup.html"><i class="flaticon-unlock"></i>登出</a></li>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <!-- profile picture end -->
                    </div>
                </div>
            </div>
        </div>
    </div>
</header>
<!-- header area end -->
<!-- header area start -->
<header>
    <div class="mobile-header-wrapper sticky d-block d-lg-none">
        <div class="mobile-header position-relative ">
            <div class="mobile-logo">
                <a href="index.html">
                    <img src="${pageContext.request.contextPath}/assets/images/logo/logo-white.png" alt="logo">
                </a>
            </div>
            <div class="mobile-menu w-100">
                <center>
                    <h1>欢迎</h1>
                </center>
            </div>
            <div class="mobile-header-profile">
                <!-- profile picture end -->
                <div class="profile-thumb profile-setting-box">
                    <a href="javascript:void(0)" class="profile-triger">
                        <figure class="profile-thumb-middle">
                            <img src="${pageContext.request.contextPath}/assets/images/profile/profile-small-1.jpg" alt="profile picture">
                        </figure>
                    </a>
                    <div class="profile-dropdown text-left">
                        <div class="profile-head">
                            <h5 class="name"><a href="#">昵称</a></h5>
                            <a class="mail" href="#">用户名</a>
                        </div>
                        <div class="profile-body">
                            <ul>
                                <li><a href="profile.html"><i class="flaticon-user"></i>个人中心</a></li>
                                <li><a href="#"><i class="flaticon-document"></i>我的动态</a></li>
                            </ul>
                            <ul>
                                <li><a href="signup.html"><i class="flaticon-unlock"></i>登出</a></li>
                            </ul>
                        </div>
                    </div>
                </div>
                <!-- profile picture end -->
            </div>
        </div>
    </div>
</header>
<!-- header area end -->

<main>

    <div class="main-wrapper pt-80">
        <div class="container">
            <div class="row">
                <div class="col-lg-3 order-2 order-lg-1">
                    <aside class="widget-area">
                        <!-- widget single item start -->
                        <div class="card card-profile widget-item p-0">
                            <div class="profile-banner">
                                <div class="profile-desc text-center">
                                    <h6 class="author"><a href="profile.html">站长公告</a></h6>
                                    <p>欢迎且感谢来到我的网站玩耍，水平有限bug可能会有点多，反馈即可，不过反馈了也不一定解决</p>
                                </div>
                            </div>
                        </div>
                        <!-- widget single item start -->



                        <!-- widget single item start -->
                        <div class="card widget-item">
                            <h4 class="widget-title">比较热门的动态</h4>
                            <div class="widget-body">
                                <ul class="like-page-list-wrapper">
                                    <li class="unorder-list">
                                        <!-- profile picture end -->
                                        <div class="profile-thumb">
                                            <a href="#">
                                                <figure class="profile-thumb-small">
                                                    <img src="${pageContext.request.contextPath}/assets/images/profile/profile-small-28.jpg" alt="profile picture">
                                                </figure>
                                            </a>
                                        </div>
                                        <!-- profile picture end -->

                                        <div class="unorder-list-info">
                                            <h3 class="list-title"><a href="#">Any one can join with us if you want</a></h3>
                                            <p class="list-subtitle">2 min ago</p>
                                        </div>
                                    </li>

                                </ul>
                            </div>
                        </div>
                        <!-- widget single item end -->
                    </aside>
                </div>

                <div class="col-lg-6 order-1 order-lg-2">
                    <!-- share box start -->
                    <div class="card card-small">
                        <div class="share-box-inner">
                            <!-- profile picture end -->
                            <div class="profile-thumb">
                                <a href="#">
                                    <figure class="profile-thumb-middle">
                                        <img src="<%= pic.getPath()%>" alt="profile picture">
                                    </figure>
                                </a>
                            </div>
                            <!-- profile picture end -->

                            <!-- share content box start -->
                            <div class="share-content-box w-100">
                                <form class="share-text-box">
                                    <textarea name="发布" class="share-text-field" aria-disabled="true" placeholder="Say Something" data-toggle="modal" data-target="#textbox" id="email"></textarea>
                                    <button class="btn-share" type="submit">分享你所享</button>
                                </form>
                            </div>
                            <!-- share content box end -->

                            <!-- Modal start -->
                            <div class="modal fade" id="textbox" aria-labelledby="textbox">
                                <div class="modal-dialog">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <h5 class="modal-title">发布动态</h5>
                                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                <span aria-hidden="true">&times;</span>
                                            </button>
                                        </div>
                                        <div class="modal-body custom-scroll">
                                            <textarea name="share" class="share-field-big custom-scroll" placeholder="写点什么吧~~" maxlength="250"></textarea>
                                        </div>
                                        <div class="modal-footer">
                                            <button type="button" class="post-share-btn" data-dismiss="modal">不发啦</button>
                                            <button type="button" class="post-share-btn">发布</button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <!-- Modal end -->
                        </div>
                    </div>
                    <!-- share box end -->

                    <!-- post status start -->
                    <div class="card">
                        <!-- post title start -->
                        <div class="post-title d-flex align-items-center">
                            <!-- profile picture end -->
                            <div class="profile-thumb">
                                <a href="#">
                                    <figure class="profile-thumb-middle">
                                        <img src="<%=findShareProfile(userShareTime.get(0).getUser_id(),users,pictureList)%>" alt="profile picture">
                                    </figure>
                                </a>
                            </div>
                            <!-- profile picture end -->

                            <div class="posted-author">
                                <h6 class="author"><a href="profile.html"><%= findShareUser(userShareTime.get(0).getUser_id(),users)%></a></h6>
                                <span class="post-time"><%= userShareTime.get(0).getTime() %></span>
                            </div>

                        </div>
                        <!-- post title start -->
                        <div class="post-content">
                            <p class="post-desc">
                               <%= userShareTime.get(0).getContent() %>
                            </p>
                            <div class="post-thumb-gallery">
                                <figure class="post-thumb img-popup">
                                    <a href="<%= findSharePic(userShareTime.get(0).getPic_id(),pictureList) %>">
                                        <img src="<%= findSharePic(userShareTime.get(0).getPic_id(),pictureList) %>" alt="post image">
                                    </a>
                                </figure>
                            </div>
                            <div class="post-meta">
                                <button class="post-meta-like">
                                    <i class="bi bi-heart-beat"></i>
                                    <span>有<%= userShareTime.get(0).getLike() %>个憨憨和你一起表示了喜欢</span>
                                    <strong><%= userShareTime.get(0).getLike() %></strong>
                                </button>
                                <ul class="comment-share-meta">
                                    <li>
                                        <button class="post-comment">
                                            <i class="bi bi-chat-bubble"></i>
                                            <span>#功能待添加</span>
                                        </button>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </div>
                    <!-- post status end -->
                    <%
                        int i = 1;
                        while(i<userShareTime.size()){
                    %>
                    <!-- post status start -->
                    <div class="card">
                        <!-- post title start -->
                        <div class="post-title d-flex align-items-center">
                            <!-- profile picture end -->
                            <div class="profile-thumb">
                                <a href="#">
                                    <figure class="profile-thumb-middle">
                                        <img src="<%=findShareProfile(userShareTime.get(i).getUser_id(),users,pictureList)%>" alt="profile picture">
                                    </figure>
                                </a>
                            </div>
                            <!-- profile picture end -->

                            <div class="posted-author">
                                <h6 class="author"><a href="profile.html"><%= findShareUser(userShareTime.get(0).getUser_id(),users)%></a></h6>
                                <span class="post-time"><%= userShareTime.get(i).getTime() %></span>
                            </div>

                        </div>
                        <!-- post title start -->
                        <div class="post-content">
                            <p class="post-desc">
                                <%= userShareTime.get(i).getContent() %>
                            </p>
                            <div class="post-thumb-gallery">
                                <figure class="post-thumb img-popup">
                                    <a href="<%= findSharePic(userShareTime.get(i).getPic_id(),pictureList) %>">
                                        <img src="<%= findSharePic(userShareTime.get(i).getPic_id(),pictureList) %>" alt="post image">
                                    </a>
                                </figure>
                            </div>
                            <div class="post-meta">
                                <button class="post-meta-like">
                                    <i class="bi bi-heart-beat"></i>
                                    <span>有<%= userShareTime.get(i).getLike() %>个憨憨和你一起表示了喜欢</span>
                                    <strong><%= userShareTime.get(i).getLike() %></strong>
                                </button>
                                <ul class="comment-share-meta">
                                    <li>
                                        <button class="post-comment">
                                            <i class="bi bi-chat-bubble"></i>
                                            <span>#功能待添加</span>
                                        </button>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </div>
                    <!-- post status end -->
                    <%
                            i++;
                        }
                    %>




                </div>

                <div class="col-lg-3 order-3">
                    <aside class="widget-area">


                        <!-- widget single item start -->
                        <div class="card widget-item">
                            <h4 class="widget-title">最近加入的同学</h4>
                            <div class="widget-body">
                                <ul class="like-page-list-wrapper">
                                    <li class="unorder-list">
                                        <!-- profile picture end -->
                                        <div class="profile-thumb">
                                            <a href="#">
                                                <figure class="profile-thumb-small">
                                                    <img src="${pageContext.request.contextPath}/assets/images/profile/profile-small-33.jpg" alt="profile picture">
                                                </figure>
                                            </a>
                                        </div>
                                        <!-- profile picture end -->

                                        <div class="unorder-list-info">
                                            <h3 class="list-title"><a href="#">Ammeya Jakson</a></h3>
                                            <p class="list-subtitle"><a href="#">10 mutual</a></p>
                                        </div>
                                        <button class="like-button">
                                            <img class="heart" src="${pageContext.request.contextPath}/assets/images/icons/heart.png" alt="">
                                            <img class="heart-color" src="${pageContext.request.contextPath}/assets/images/icons/heart-color.png" alt="">
                                        </button>
                                    </li>

                                </ul>
                            </div>
                        </div>
                        <!-- widget single item end -->

                        <!-- widget single item start -->
                        <div class="card widget-item">
                            <h4 class="widget-title">广告位</h4>
                            <div class="widget-body">
                                <div class="add-thumb">
                                    <a href="#">
                                        <img src="${pageContext.request.contextPath}/assets/images/banner/advertise.jpg" alt="advertisement">
                                    </a>
                                </div>
                            </div>
                        </div>
                        <!-- widget single item end -->


                    </aside>
                </div>
            </div>
        </div>
    </div>

</main>

<!-- Scroll to top start -->
<div class="scroll-top not-visible">
    <i class="bi bi-finger-index"></i>
</div>
<!-- Scroll to Top End -->

<!-- footer area start -->

<!-- footer area end -->

<!-- footer area start -->

<!-- 不会写页脚妈的-->

<!-- footer area end -->

<!-- JS
============================================ -->

<!-- Modernizer JS -->
<script src="${pageContext.request.contextPath}/assets/js/vendor/modernizr-3.6.0.min.js"></script>
<!-- jQuery JS -->
<script src="${pageContext.request.contextPath}/assets/js/vendor/jquery-3.3.1.min.js"></script>
<!-- Popper JS -->
<script src="${pageContext.request.contextPath}/assets/js/vendor/popper.min.js"></script>
<!-- Bootstrap JS -->
<script src="${pageContext.request.contextPath}/assets/js/vendor/bootstrap.min.js"></script>
<!-- Slick Slider JS -->
<script src="${pageContext.request.contextPath}/assets/js/plugins/slick.min.js"></script>
<!-- nice select JS -->
<script src="${pageContext.request.contextPath}/assets/js/plugins/nice-select.min.js"></script>
<!-- audio video player JS -->
<script src="${pageContext.request.contextPath}/assets/js/plugins/plyr.min.js"></script>
<!-- perfect scrollbar js -->
<script src="${pageContext.request.contextPath}/assets/js/plugins/perfect-scrollbar.min.js"></script>
<!-- light gallery js -->
<script src="${pageContext.request.contextPath}/assets/js/plugins/lightgallery-all.min.js"></script>
<!-- image loaded js -->
<script src="${pageContext.request.contextPath}/assets/js/plugins/imagesloaded.pkgd.min.js"></script>
<!-- isotope filter js -->
<script src="${pageContext.request.contextPath}/assets/js/plugins/isotope.pkgd.min.js"></script>
<!-- Main JS -->
<script src="${pageContext.request.contextPath}/assets/js/main.js"></script>

</body>

</html>
